// import fs from 'fs';
// import FormData from 'form-data';
// import fetch from 'node-fetch';

// let file = fs.readFileSync('./public/file/屏幕截图 2022-05-17 153244.png',{
//     encoding: 'base64'
// });

// let formData = new FormData();
// formData.append('base64', file);
// formData.append('uri', '屏幕截图 2022-05-17 153244.png');

// fetch('http://10.7.85.155:2333/fileupload', {
//     method: 'post',
//     headers: {
//         ContentType: 'application/x-www-form-urlencoded'
//     },
//     body: formData
// }).then(res=>res.json()).then(data=>console.log(data))


/**
 * @param {string} s
 * @return {number}
 */
var romanToInt = function (s) {
    var alth = {
        I: 1,
        V: 5,
        X: 10,
        L: 50,
        C: 100,
        D: 500,
        M: 1000
    }
    var stack = [];
    let top;
    for (let char of s) {
        top = stack.pop();
        if (top == null) {
            stack.push(alth[char]);
        } else if (top >= alth[char]) {
            stack.push(top);
            stack.push(alth[char]);
        } else if (top < alth[char]) {
            stack.push(-top);
            stack.push(alth[char]);
        }
    }
    // for (let i = 0; i < s.length; i++) {
    //     let rNum = s.charAt(i);
    //     let top = stack.pop();
    //     if (top == null) {
    //         stack.push(alth[rNum]);
    //     } else if (top >= alth[rNum]) {
    //         stack.push(top);
    //         stack.push(alth[rNum]);
    //     } else if (top < alth[rNum]) {
    //         stack.push(-top);
    //         stack.push(alth[rNum]);
    //     }
    // }
    let sum = 0;
    for (let i = 0; i < stack.length; i++) {
        sum += stack[i];
    }
    return sum;
};